package jdx_05_synchronized.jdx_02_小程序测试;

/*
这里就可以正常的执行，达到预期的目标
 */
public class T2 implements Runnable{
    private int count = 100;

    @Override
    //这里加锁试试看
    public synchronized void run() {
        count--;
        System.out.println(Thread.currentThread().getName()+"\tcount="+count);
    }

    public static void main(String[] args) {
        T2 t = new T2();
        for (int i = 0; i < 100; i++) {
            String index = ""+i;
            if(i<10){
                index = "0"+i;
            }
            new Thread(t,"Thread"+index).start();
        }
    }
}
